/*
 * singletest.c: test /dev/
 *
 * Copyright (C) 2001 Alessandro Rubini and Jonathan Corbet
 * Copyright (C) 2001 O'Reilly & Associates
 *
 * The source code in this file can be freely used, adapted,
 * and redistributed in source or binary form, so long as an
 * acknowledgment appears in derived source files.  The citation
 * should list that the code comes from the book "Linux Device
 * Drivers" by Alessandro Rubini and Jonathan Corbet, published
 * by O'Reilly & Associates.   No warranty is attached;
 * we cannot take responsibility for errors or fitness for use.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>

#define SCULLWUID   "/dev/scullwuid"

char buffer[4096];

int main(int argc, char **argv)
{
    int count;
    int fd_wuid = 0;

    fd_wuid = open(SCULLWUID, O_RDWR);
    if(0 > fd_wuid){
        perror("can not open file");
        return -1;
    }

    while(1) {
        count=read(fd_wuid, buffer, 4096);
        /* buggy: if avail data is more than 4kbytes... */
        write(1, buffer, count);
        sleep(5);
    }

    close(fd_wuid);
    return 0;
}
